﻿<UserControl x:Class="ScrumFactory.ProjectTeam.ProjectTeam"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                                       
             xmlns:props="clr-namespace:ScrumFactory.ProjectTeam.Properties"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             x:Name="thisView"
             
             mc:Ignorable="d" 
             
             d:DesignHeight="300" d:DesignWidth="300">   
    
    <Grid HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ToolBar Grid.Row="0">
            <Menu>
                <MenuItem Header="{x:Static props:Resources.Add_member}"
                          ItemsSource="{Binding Roles}">
                    <MenuItem.ItemContainerStyle>
                        <Style TargetType="MenuItem">
                            <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubmenuItem}"/>
                            <Setter Property="Command" Value="{Binding ElementName=thisView, Path=DataContext.AddNewMemberCommand}"/>
                            <Setter Property="CommandParameter" Value="{Binding Role}"/>
                        </Style>
                    </MenuItem.ItemContainerStyle>
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/TeamMember.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                    
                    <MenuItem.ItemTemplate>
                        <DataTemplate>                            
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <Image Source="/Images/ToolBar/TeamMember.png" Width="16" Height="16" Stretch="Uniform" Margin="0,0,5,0"/>                                
                                <TextBlock Foreground="{StaticResource ToolBarMenuForegroundBrush}" Text="{Binding Role.RoleName}" VerticalAlignment="Center" />
                            </StackPanel>
                        </DataTemplate>
                    </MenuItem.ItemTemplate>
                </MenuItem>
            
            
            <MenuItem Header="{x:Static props:Resources.Roles}" Command="{Binding ShowRolesListCommand}">
                <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/editRoles.png" Width="32" Height="32" Stretch="Uniform"/>
                </MenuItem.Icon>
            </MenuItem>

            </Menu>
        </ToolBar>


        <ListBox
            Grid.Row="1"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            HorizontalAlignment="Stretch"
            Background="Transparent"
            BorderThickness="0"
            ItemContainerStyle="{StaticResource NoHoverListBoxItem}"
            ItemsSource="{Binding GroupedProjectMemberships}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>       
            <ListBox.GroupStyle>
                <GroupStyle>                    
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock
                                Margin="0,5,0,5"
                                Foreground="{StaticResource GroupTitleBrush}" FontSize="{StaticResource BigFontSize}"
                                Text="{Binding Path=Name, StringFormat='{}{0}(s)'}"/>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListBox.GroupStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    
                        <Grid>
                            <Grid.ColumnDefinitions>                            
                                <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="200"/>
                        </Grid.ColumnDefinitions>
                        <ComboBox                                                                    
                                    Grid.Column="0"
                                    Margin="0,2,0,0" VerticalAlignment="Top"
                                    Style="{StaticResource MemberAllocationComboBox}"                                    
                                    SelectedValue="{Binding DayAllocation}"/>
                        <ContentControl
                                Grid.Column="1"
                                Margin="5,0,10,0"
                                HorizontalAlignment="Center" VerticalAlignment="Top"
                                Style="{StaticResource MemberImageControlStyle}"/>
                            
                            
                            
                        <StackPanel Grid.Column="2">
                            
                                <TextBlock
                                    Foreground="{StaticResource TitleTextBrush}" VerticalAlignment="Top"                               
                                    Text="{Binding MemberProfile.FullName}" TextTrimming="CharacterEllipsis"/>
                            
                            <TextBlock Foreground="{StaticResource SubTextBrush}" FontSize="{StaticResource SmallFontSize}" Text="{Binding MemberProfile.CompanyName}"  TextTrimming="CharacterEllipsis"/>
                                <TextBlock>                                
                                    <Hyperlink  NavigateUri="mailto:marcos.dobay@hotmail.com.br">
                                        <TextBlock Text="{Binding MemberProfile.EmailAccount}" FontSize="{StaticResource SmallFontSize}" TextTrimming="CharacterEllipsis"/>    
                                    </Hyperlink>
                                </TextBlock>                                                        
                            <Button
                                    x:Name="removeButton"
                                    HorizontalAlignment="Right"
                                    Opacity="0"
                                    Style="{StaticResource RemoveButton}"
                                    Command="{Binding ElementName=thisView, Path=DataContext.RemoveMemberCommand}"
                                    CommandParameter="{Binding .}"/>
                            
                            <StackPanel.Triggers>
                                <EventTrigger RoutedEvent="DockPanel.MouseEnter">
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation
                                                        Storyboard.TargetName="removeButton" 
                                                        Storyboard.TargetProperty="Opacity"
                                                        From="0" To="1" Duration="00:00:01" 
                                                        FillBehavior="HoldEnd" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                                <EventTrigger RoutedEvent="DockPanel.MouseLeave">
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation
                                                        Storyboard.TargetName="removeButton" 
                                                        Storyboard.TargetProperty="Opacity"
                                                        From="1" To="0" Duration="0" 
                                                        FillBehavior="HoldEnd" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                            </StackPanel.Triggers>
                        </StackPanel>
                        
                    </Grid>                        
                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


    </Grid>
</UserControl>
